package com.atguigu.gulimall.threepary.controller;

import com.atguigu.common.utils.R;
import com.atguigu.gulimall.threepary.phone.Phone;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/third")
public class SmsPhoneController {

    @Autowired
    StringRedisTemplate redisTemplate;

    @Autowired
    Phone phone1;

    @GetMapping("/sms")
    public R SmsPhone(@RequestParam("phone") String phone,@RequestParam("code")String code){
//        //生成四位数的验证码
//        Integer v =  (int)((Math.random() + 1) * 1000);
//        String code = v.toString();
//        //把验证码存入redis中
//        redisTemplate.opsForValue().set(SmsConstant.SMS_PHONE+phone,code,3, TimeUnit.MINUTES);
//        Phone phone1 = new Phone();
        phone1.sms(phone,code,"3");
        return R.ok();
    }
}
